import * as signalR from "@aspnet/signalr";
function webSocket() {
  var webSocket = new WebSocket('wss://ohaigk.zjhlang.com/SignalR/hubs/chathub')
  webSocket.onopen = function (event) {
    // setInterval(function () {
    //   webSocket.send('收到消息')
    // }, 10000)
  }

  webSocket.onmessage = function (event) {
    let data = event.data
    msg.text = text; // 文字内容: 小朋友，你是否有很多问号
    msg.lang = "zh-CN"; // 使用的语言:中文
    msg.volume = 1; // 声音音量：1
    msg.rate = 1; // 语速：1
    msg.pitch = 1; // 音高：1
    synth.speak(msg); // 播放
    Message({
      showClose: true,
      message: data,
      type: 'success',
      duration: 0
    })
    // router.push({path: '/orderList'})
  }
  webSocket.onerror = function (event) {
  }
  webSocket.onclose = function (event) {
  }
  window.onbenforeunload = function () {
    webSocket.close()
  }
}

export default { webSocket }
